import { ApiProperty, IntersectionType, PartialType } from '@nestjs/swagger'
import { IsEnum, IsOptional, IsString } from 'class-validator'

import { PagerDto } from '~/common/dto/pager.dto'
import { StudentStatus, StudentType } from '../entities/student.entity'

export class StudentBaseQueryDto {
  @ApiProperty({ description: '学生ID', required: false })
  @IsOptional()
  @IsString()
  studentId?: string

  @ApiProperty({ description: '手机号', required: false })
  @IsOptional()
  @IsString()
  phone?: string

  @ApiProperty({ description: '学生姓名', required: false })
  @IsOptional()
  @IsString()
  userName?: string

  @ApiProperty({ description: '学生状态', enum: StudentStatus, required: false })
  @IsOptional()
  @IsEnum(StudentStatus)
  status?: StudentStatus

  @ApiProperty({ description: '学生类型', enum: StudentType, required: false })
  @IsOptional()
  @IsEnum(StudentType)
  studentType?: StudentType
}

export class QueryStudentDto extends IntersectionType(PagerDto<StudentBaseQueryDto>, PartialType(StudentBaseQueryDto)) {}